home *** CD-ROM | disk | FTP | other *** search
- ` ------------------------------------------------------------------------
- ` Pure Text Scroller DarkForge Snippet (12/10/2000)
- ` ------------------------------------------------------------------------
- ` This routine is nice, fast, works in whatever resolution you want and
- ` creates a cool, fast scroller using text only (no external graphics)
- ` Infact it's fast enough to have the entire screen full of scrollers!
- ` See further down the code for the line to change to make this work.
-
- hide mouse
- sync rate 0
- sync on
-
- ` Make our font set (uses the Courier font 10x12 pixels)
-
- set text font "Courier"
- set text size 10
-
- sw = screen width()
- sh = screen height()
- cps = sw/10
-
- create bitmap 2,sw,sh
-
- x=0 : y=0
-
- for a=32 to 122
-
- ` Uncomment these 4 lines for a better looking "wind-swept" font
-
- ` ink rgb(0,100,0),0
- ` text x+2,y,chr$(a)
- ` ink rgb(0,175,0),0
- ` text x+1,y,chr$(a)
-
- ink rgb(0,255,0),0
- text x,y,chr$(a)
-
- inc x,10
-
- if x=>sw
- inc y,12
- x=0
- endif
-
- next a
-
- ` Grab the font into images. We're using image numbers 32 to 122 so they
- ` map to the ASCII values. It's lazy but it works faster.
-
- x=0 : y=0
-
- for a=32 to 122
- get image a,x,y,x+10,y+12
- inc x,10
- if x=>sw
- inc y,14
- x=0
- endif
- next a
-
- cls 0
-
- ` Get the size of the scroll text data
-
- restore scrolltext
- scroll_lines = 0
- scroll_length = 0
-
- repeat
- read temp$
- inc scroll_lines
- scroll_length = scroll_length + len(temp$)
- until temp$=" "
-
- ` Read the text into an array called s$()
-
- restore scrolltext
-
- dim s$(scroll_length+cps)
- a=0
-
- repeat
-
- read temp$
-
- for b=0 to len(temp$)
- temp_char$=mid$(temp$,b)
- s$(a)=temp_char$
- inc a
- next b
-
- until temp$=" "
-
- ` That's the text sorted. Now let's display it
-
- set text opaque
- create bitmap 1,sw,sh
-
- sl=scroll_length+cps
- x1#=sw
- x2#=sw+sw
- speed#=4
-
- pointer=MakeLine(1,0,cps,sl)
- pointer=MakeLine(2,pointer,cps,sl)
-
- ` Set "texts" to 1 or 0, 1 is a single scroller, 0 is 30!
-
- texts=0
-
- do
-
- if texts=1
- paste image 1,x1#,0
- paste image 2,x2#,0
- else
- for a=0 to sh step 15
- paste image 1,x1#,a
- paste image 2,x2#,a
- next a
- endif
-
- dec x1#,speed#
- dec x2#,speed#
-
- neg_sw#=1-(sw+1)
-
- if x1#=<neg_sw#
- pointer=MakeLine(1,pointer,cps,sl)
- x1#=sw
- endif
-
- if x2#=<neg_sw#
- pointer=MakeLine(2,pointer,cps,sl)
- x2#=sw
- endif
-
- ` Uncomment for the FPS
- ` text 0,0,str$(screen fps())
-
- copy bitmap 1,0
- sync
-
- loop
-
-
-
- ` - DF Function --------------------------------------------------------
- ` This creates the next image (i) of text, c=current position
- ` -------------------------------------------------------- DF Function -
-
- function MakeLine(i,c,cps,sl)
-
- set current bitmap 2
-
- for a=0 to cps-1
- t$=s$(c)
- pi=asc(t$)
- if pi=0 then pi=32
- paste image pi,a*10,0
- inc c
- if c>sl then c=0
- next a
-
- get image i,0,0,screen width(),13
- cls 0 : set current bitmap 1
-
- endfunction c
-
- ` - DF Data ------------------------------------------------------------
- ` The actual data, terminate with a single space on its own
- ` ------------------------------------------------------------ DF Data -
-
- scrolltext:
- data "DARKFORGE PRESENT TO YOU A COMPLETE TEXT-BASED SCROLLER THAT"
- data "DOES NOT NEED ANY EXTERNAL GRAPHICS FILES! IT'S ALSO FAST AND"
- data "SMOOTH SO NO WORRIES ABOUT CPU OVERHEAD HERE :-) "
- data "THIS ONE WAS A TRIAL TO SEE HOW MANY LITTLE SCROLLERS I COULD"
- data "GET ON-SCREEN AT ONCE AND I AM QUITE HAPPY WITH THE RESULTS! NO LESS"
- data "THAN 30 OF THE SUCKERS AND ALL MOVING AT A DECENT FRAME RATE."
- data "IF YOU CAN'T SEE 30 OF THEM, THEN FIND THE TEXTS VALUE AND ALTER IT"
- data "QUICKLY! IT LOOKS REALLY NICE WITH LOTS OF THINGS GOING ON :-) ..."
- data "GOD I LOVE DARKBASIC SOMETIMES, AND TO ALL THOSE WHO SAY IT CAN'T"
- data "HACK IT AT 2D - SCREW YOU! YOU'RE JUST NOT AS GOOD AS ME ;-)"
- data " ... OKAY SOME GREETINGS I THINK ... HELLO TO THE FOLLOWING PEOPLE"
- data "- TRACER FOR YOUR DOTS DUDE, ASMPROGRAMMER FOR YOUR BETA TESTING,"
- data "BIGGUN FOR YOUR COOL GRAPHICS FX, PJAY FOR JUST BEING COOL, SI FOR"
- data "HIS TRIPPY LITTLE SHEEP GAME, ALL THOSE ON THE DB FORUMS WHO AREN'T"
- data "CALLED ANTHONY (OR WHO GO ON ENDLESSLY ABOUT BLITZ, TAKE IT ELSEWHERE"
- data "PEOPLE, WE DON'T GIVE A SHIT!) AND WELL GENERALLY HI TO YOU TOO..."
- data "OKAY LET'S WRAP THIS SUCKER, IT'S FAR TOO LONG ALREADY....... WRAP!"
- data " "
-
-